
strRightmappath='C:/Experiments/Default/Image/Single/measurement00000La.tif';
strLeftmappath='C:/Experiments/Default/Image/Single/measurement00000Ra.tif';
% XcorMapWholeFieldExtend(0,strRightmappath,strLeftmappath,...
%     './',  16, 0, 0,0,0,1,128,0,1,50,0);%
nsize = size(strRightmappath)-4;
Num = strfind(strRightmappath,'/');
lenNum = Num(length(Num));
str = strRightmappath(lenNum+1:nsize(2));
str = sprintf('%s/%s_deta%d', './',str,1);
load(str);
detaX = X2m-X1m;
detaY = Y2m - Y1m;
    DX=find(detaX==0);
    DY=find(detaY==0);
    DeletePoint=intersect(DX,DY);
    %     if n>7
    detaX(DeletePoint)=0;
    detaY(DeletePoint)=0;
    D=sqrt(detaX.^2+detaY.^2);
    DeletePoint=union(DeletePoint,find(D>50));
    DeletePoint=union(DeletePoint,find(D<10));
    D=ToMatrix(D,outx,outy);
    b=fspecial('gaussian',[9 9],5);
    d=imfilter(D,b);
    M=D-d;
    %         DeletePoint=union(find(ToLine(M,1)>mean(mean(M)+1)),DeletePoint);
    d=[0.5];
    DeletePoint=union(find(abs(ToLine(M,1))>d),DeletePoint);
    detaX(DeletePoint)=0;
    detaY(DeletePoint)=0;
    X2m(DeletePoint)=[];
X1m(DeletePoint)=[];
Y2m(DeletePoint)=[];
Y1m(DeletePoint)=[];
figure;surf(ToMatrix(sqrt(detaX.^2+detaY.^2),outx,outy));


X2m(DeletePoint)=0;
X1m(DeletePoint)=0;
Y2m(DeletePoint)=0;
Y1m(DeletePoint)=0;
X1m=ToMatrix(X1m,outx,outy);Y1m=ToMatrix(Y1m,outx,outy);
X2m=ToMatrix(X2m,outx,outy);Y2m=ToMatrix(Y2m,outx,outy);

x=15;y=27;
POSR=[X1m(y,x),Y1m(y,x)];
POSL=[X2m(y,x),Y2m(y,x)];
save('outposa1.mat','POSL');
save('outposb1.mat','POSR');